#!/usr/bin/python3
#coding=utf8

import requests,time,execjs

def get_safe(current_time):
  #   js=execjs.compile(''' 
  #       const jsdom = require("jsdom");
		# const { JSDOM } = jsdom;
		# const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
		# window = dom.window;
		# document = window.document;
		# XMLHttpRequest = window.XMLHttpRequest;

  #       ''')
    
	# with open(r'jsdom.js','r',encoding='utf-8') as f:
	#     jsdom = f.read()
    # ct = execjs.compile(r'D:\TestCode\self_spider\test.js',cwd=r'D:\laragon\bin\nodejs\node-v12\node_modules')
    # 
    with open(r'D:\TestCode\self_spider\test.js', encoding='utf-8') as f:
        js = f.read()

    ct = execjs.compile(js,cwd=r'D:\laragon\bin\nodejs\node-v12\node_modules')
	# print(ct.call('Rohr_Opt.reload','1'))
    return ct.call('return_tokens',current_time)
    # print(type(current_time))
    # print(ct)
    # print(ct.call('return_tokens',current_time))


# 参考的页面 有 
# https://stackoverflow.com/questions/64874484/js-referenceerror-fetch-is-not-defined
# https://cloud.tencent.com/developer/article/1647615
# https://www.cnblogs.com/songzhixue/p/11242221.html


current_time = str(1629300036)
print(current_time)
print(get_safe(current_time))
